<%@page import="org.nutz.lang.Times"%>
<%@page import="org.nutz.json.Json"%>
<%@page import="com.acic.jba.bean.Receipt"%>
<%@page import="com.assic.utils.vo.Result"%>
<%@page import="com.assic.utils.vo.OperationState"%>
<%@page import="java.util.Map"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://ixion.net/tag/it" prefix="it"%>
<%
	String path = request.getContextPath();
	String title = "";
	String key = "data";
	Map<String, Object> data = null;
	OperationState state = OperationState.DEFAULT;
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
	Result result = (Result) request.getAttribute("obj");
	if (result != null) {
		title = result.getTitle();
		data = result.getData();
		state = result.getOperationState();
	}
	application.setAttribute("base", basePath);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="<%=basePath%>js/jquery.js"></script>
<script src="<%=basePath%>bootstrap/js/bootstrap.min.js"></script>
<link href="<%=basePath%>bootstrap/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="<%=basePath%>js/lhgdialog.js?self=true&skin=iblack"></script>
<!--[if lte IE 9]>
<script src="<%=basePath%>bootstrap/js/respond.min.js"></script>
<script src="<%=basePath%>bootstrap/js/html5shiv.min.js"></script>
<![endif]-->
<style type="text/css">
caption {
	font-size: 24px;
}

.table {
	width: 98%;
	margin-left: 1%;
	margin-right: 1%;
}
</style>
</head>
<body>
	<%
		Receipt receipt = (Receipt) data.get("receipt");
	%>
	<div style="margin-top: 20px;"></div>
	<table class="table table-condensed table-striped table-responsive table-bordered">
		<tr>
			<td>报案单号</td>
			<td id="id"><%=receipt.getId()%></td>
			<td>保单效期</td>
			<td><%=(receipt.getValidTraPlyNo() == null && receipt.getValidTraPlyNo() == null)? "无保单":  receipt.isAvailableFlag() ? "有效" :"无效"%></td>
		</tr>
		<tr>
			<td>处置意见</td>
			<td id="dell"><%=receipt.isDellFlag() ? "派工":"不派工"%></td>
			<td>处置状态</td>
			<td><span id="force" style="margin-right: 5px"> <%=receipt.getDellStatus()%>
			</span> | 已来电 <span id="times" style="color: red"><%=receipt.getIncomeTimes()%></span> 次</td>
		</tr>
		<tr>
			<td>报案人</td>
			<td><%=receipt.getReporter()%></td>
			<td>报案人电话</td>
			<td><%=receipt.getReporterNo()%></td>
		</tr>
		<tr>
			<td>联系人</td>
			<td><%=receipt.getContact()%></td>
			<td>联系人电话</td>
			<td><%=receipt.getContactNo()%></td>
		</tr>
		<tr>
			<td>车牌号码</td>
			<td><%=receipt.getCarPlate()%></td>
			<td>涉案车辆数</td>
			<td><%=receipt.getInvolvedCarNum()%></td>
		</tr>
		<tr>
			<td>死亡人数</td>
			<td><%=receipt.getDeadNum()%></td>
			<td>受伤人数</td>
			<td><%=receipt.getInjuryNum()%></td>
		</tr>
		<tr>
			<td>物品损失</td>
			<td><%=receipt.isMaterialsDestroyFlag() ? "有" : "无"%></td>
			<td>单车事故</td>
			<td><%=receipt.isSingleCarFlag() ? "是" : "否"%></td>
		</tr>
		<tr>
			<td>出险时间</td>
			<td><%=Times.format("yyyy-MM-dd HH:mm:ss", receipt.getOccurTime())%></td>
			<td>报案时间</td>
			<td><%=Times.format("yyyy-MM-dd HH:mm:ss", receipt.getReportTime())%></td>
		</tr>
		<tr>
			<td>出险地点</td>
			<td><%=receipt.getOccurAddrInfo()%></td>
			<td>查看地点</td>
			<td><%=receipt.getCheckAddrInfo()%>   <span style="color: red;margin-left: 10px;"> <%= receipt.isCheckAddressFlag() ? "":"地址不详,查勘人员需确认地址" %>
			</span></td>
		</tr>
		<tr>
			<td>出险经过</td>
			<td><%=receipt.getDescription()%></td>
			<td>出险原因</td>
			<td><%=receipt.getReason()%></td>
		</tr>
		<tr>
			<td>巨灾</td>
			<td><%=receipt.isHugeDisasterFlag() ? "是" : "否"%></td>
			<td>代位求偿</td>
			<td><%=receipt.isAgentClaimFlag() ? "是" : "否"%></td>
		</tr>
		<tr>
			<td colspan="4"><button class="btn btn-sm btn-primary pull-right" style="width: 125px; margin-right: 10px" onclick="comfirmIncome(event);">确认报案</button>
				<button style="width: 125px; margin-right: 10px" class="btn btn-sm btn-primary pull-right <%=receipt.isDellFlag()?"hide":""%>" onclick="force(event);">强制派工</button></td>
		</tr>
	</table>
	<script type="text/javascript">
		function getRootPath() {
			var strFullPath = window.document.location.href;
			var strPath = window.document.location.pathname;
			var pos = strFullPath.indexOf(strPath);
			var prePath = strFullPath.substring(0, pos);
			var postPath = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
			return (prePath + postPath);
		}
		function comfirmIncome(e) {
			var btn = e.target;
			btn.disabled = true;
			var id = $("#id").html();
			$.post(getRootPath() + "/confirmIncome.ac", {
				id : id
			}, function(result) {
				if (result.operationState == 'SUCCESS') {
					$.dialog.tips("处理成功");
					var timesInfo = $("#times");
					timesInfo.html(parseInt(timesInfo.html()) + 1);
					var api = frameElement.api, W = api.opener;
					setTimeout(function() {
						W.enableEnd();
						api.close();
						btn.disabled = false;
					}, 3000);
				} else {
					$.dialog.tips(result.data.reason);
				}
			}, "json");
		}
		function force(e) {
			var btn = e.target;
			btn.disabled = true;
			var id = $("#id").html();
			$.post(getRootPath() + "/force.ac", {
				id : id
			}, function(result) {
				if (result.operationState == 'SUCCESS') {
					$.dialog.tips("处理成功");
					var forceInfo = $("#force");
					var dellInfo = $("#dell");
					var timesInfo = $("#times");
					timesInfo.html(parseInt(timesInfo.html()) + 1);
					forceInfo.html('强制派工成功,正在派工');
					dellInfo.html("派工");
					var api = frameElement.api, W = api.opener;
					setTimeout(function() {
						W.enableEnd();
						api.close();
						btn.disabled = false;
					}, 3000);
				} else {
					$.dialog.tips(result.data.reason);
				}
			}, "json");
		}
	</script>
</body>
</html>